package com.xt.favorites.admin.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xt.common.utils.PageUtils;
import com.xt.common.utils.Query;

import com.xt.favorites.admin.dao.UrlLibraryDao;
import com.xt.favorites.admin.entity.UrlLibraryEntity;
import com.xt.favorites.admin.service.UrlLibraryService;
import org.springframework.util.StringUtils;


@Service("urlLibraryService")
public class UrlLibraryServiceImpl extends ServiceImpl<UrlLibraryDao, UrlLibraryEntity> implements UrlLibraryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String key = (String) params.get("key");
        QueryWrapper<UrlLibraryEntity> wrapper = new QueryWrapper<>();
        //有条件就拼接参数查询
        if (!StringUtils.isEmpty(key)) {
            wrapper.eq("id",key).or().like("url",key);
        }
        IPage<UrlLibraryEntity> page = this.page(
                new Query<UrlLibraryEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}